using UnityEngine;
using QFramework;

namespace survivor
{
	public partial class EnemyGenerator : ViewController
	{
		private float mCurrentSeconds = 0;

        private void Update()
        {
            if(Player.ins == null)
                return; 
            mCurrentSeconds += Time.deltaTime;

            if (mCurrentSeconds >= 1)
            {
                mCurrentSeconds = 0;

                var player = Player.ins;
                var randomAngle = Random.Range(0, 360f);
                var randomRadius = randomAngle * Mathf.Deg2Rad;
                var direction = new Vector3(Mathf.Cos(randomRadius), Mathf.Sin(randomRadius));
                var generatePos = player.transform.position + direction * 10;

                Enemy.Instantiate().Position(generatePos).Show();
            }
        }
    }
}
